package com.value.utils;

import java.io.File;

/**
 * Value
 * <p/>
 * Copyright (c) 2012 Value ValueSoft Inc., All rights reserved.
 * <p/>
 * This software is the confidential and proprietary information of
 * ValueSoft Company. ("Confidential Information").  You shall not
 * disclose such Confidential Information and shall use it only in
 * accordance with the terms of the license agreement you entered into
 * with ValueSoft.com.
 * <p/>
 * Revision History
 * Date      		Programmer       Notes
 * 14-4-1   	     libo		     Initial
 * *********************************************************************
 */
public class FileUtils {
    /**
     * 创建文件夹
     *
     * @param filePath
     */
    public static void mkdir(String filePath) {
        if (filePath != null && !"".equals(filePath)) {
            File file = new File(filePath);
            if (!file.exists()) {
                file.mkdirs();
            }
        }
    }

    /**
     * 删除文件夹
     * @param dir
     */
    public static void deleteFolder(File dir) {
        if(dir.exists()){
            File fileList[] = dir.listFiles();
            for (File file : fileList) {
                if (file.isDirectory()) {
                    deleteFolder(file);
                } else {
                    file.delete();
                }
            }
            dir.delete();//删除当前目录
        }
    }
}
